﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace FFmpegVideoClip.Lib.UtilityControlsTools
{
    [ValueConversion(typeof(double), typeof(string))]
    internal class DoubleSecondToString : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Tools.GetTimeSpanToString_Digit(TimeSpan.FromSeconds((double)value));
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Tools.GetStringTimeToTimeSpan(value?.ToString() ?? "00:00:00.000").TotalSeconds;
        }
    }
}
